﻿<?php
	ini_set('display_errors', true);
	error_reporting(E_ALL);
	echo "<b>Velkommen til HISF sitt ipam system</b>";
	echo "<br />";
	
	require 'database.php';
		
?> 	
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	
		<title>HISF ipam (ip address management)</title>
		<link rel="stylesheet" type="text/css" href="/hisfipam/index.css">
		<link rel="stylesheet" type="text/css" href="/hisfipam/script/themes/blue/style.css">
		<script type="text/javascript" src="index.js"></script>
		<script type="text/javascript" src="/hisfipam/script/jquery-1.8.3.js"></script>
		<script type="text/javascript" src="/hisfipam/script/jquery.tablesorter.js"></script>
	</head>
	<body>
		
		
		<a href="index.php">Tilbake til start</a>
		<br/>
		
		<div id="subnett_sok">
			Hent subnett oversikt
			<button onclick="loadXMLDoc('subn')" id="hentSubnButton"> Hent </button>
		</div>
				
		<div id="vlan_dropdown_div">
			<form action="index.php" method="post">
				Henter alle adresser på et gitt vlan
				<br />
				Vlan:
				<select value="vlan_dropdown" name="vlan_dropdown" id="vlan_dropdown">
					<?php
						$database = new database();
						$vlan = array();
						$vlan = $database->hentVlan();
						$counter = 0;
						if (!isset($vlan))
							alertDebug("vlan variabel har ikke blitt satt");
						
						else {
							while ($counter < count($vlan)) {
								//alertDebug($vlan[$counter]['id']." ".$vlan[$counter]['beskrivelse']);
								echo "<option value='".$vlan[$counter]['id']."'>".$vlan[$counter]['id']." ".$vlan[$counter]['beskrivelse']."</option>";
								$counter++;
							}
						}
					?>
				</select>
				<input type="button" onclick="loadXMLDoc('vlan')" value="Hent">
			</form>
		</div>
				
		<div id="ip_sok">		
			<form action="index.php" method="post">
				Søketekst:
				<input type="text" name="ip_adresse" id="sokeFelt">
				<input type="button" onclick="loadXMLDoc('ipSok')" value="Søk">
			</form>
		</div>
		<div>
			<p> Infoen kommer nedenfor </p>
		</div>
		<div id="display_area">
			<!-- div tag for som blir oppdatert med diverse innhold etterhvert som siden blir brukt -->
		</div>
		<div id='antLedigeDisplay'>
			<?php
				$database = new database();
				$vlan = array();
				$vlan = $database->hentVlan();
				$counter = 0;
				
				echo "<p> Antall ledige adresser </p>";
				//echo "<div id='antLedigeDisplayOverskrift'>Antall ledige adresser</div>";
				
				
				echo "<table border='1' id='infoTable' class='ledigeAdresser'>
						<tbody>
							<tr>";
							
				while ($counter < count($vlan)) {
					if ($database->hentLedigeAdresser($vlan[$counter]['id']) == 0) {
						echo "<td><font color='red'>Vlan " . $vlan[$counter]['id'] . " " . $vlan[$counter]['beskrivelse'] . ": " . $database->hentLedigeAdresser($vlan[$counter]['id']) . " </font></td>";
					}
					
					else {
						echo "<td><font color='green'>Vlan " . $vlan[$counter]['id'] . " " . $vlan[$counter]['beskrivelse'] . ": " . $database->hentLedigeAdresser($vlan[$counter]['id']) . " </font></td>";
					}
					$counter++;
					if ($counter % 8 == 0) {
						echo "</tr><tr>";
					//echo "<br />";
					}
						
				}
				echo "</tr></tbody></table>"
			?>
		</div>
	</body>
</html>
	
 